<?php
/**
 * <pre>
 * <b>RUBIK IT Solution & Development ltd.</b>
 *
 * PROJECT      : rubik-base
 * COPYRIGHT    : 2008
 * ------------------------------------------------------
 * 
 * [GENERAL INFO OF THIS FILE] 
 *
 * </pre>
 * 
 * @version 		1.0
 * @author			Dang Nhon Hoa <HoaDN@rubik.com.vn>
 * @access			public
 * @package			rubik.base.misc
 *
 * Created on	: May 16, 2008
 */

class SelectResult {
	var $_totalRecords;
	var $recordSet;
	var $indexPage;
	var $recordPerPage;
	
	/**
	 * Constructor
	 *
	 * @return SelectResult
	 */
	function SelectResult() {
		$this->recordSet = array ();
	}
	
	/**
	 * Get the total record of select result.
	 * If user don't specified this value --> it will get the number of $recordSet
	 *
	 * @return int
	 */
	function getTotalRecords() {
		if (empty ( $this->_totalRecords )) {
			$this->_totalRecords = count ( $this->recordSet );
		}
		return $this->_totalRecords;
	}
	
	/**
	 * Set value for _totalRecord
	 *
	 * @param int $totalRecord
	 */
	function setTotalRecords($totalRecord) {
		$this->_totalRecords = $totalRecord;
	}
	
	/**
	 * Get the record set value.
	 *
	 * @return array
	 */
	function getRecordSet() {
		return $this->recordSet;
	}
	
	/**
	 * Set the record set value
	 *
	 * @param array $recordSet
	 */
	function setRecordSet($recordSet) {
		$this->recordSet = $recordSet;
	}
	
	/**
	 * Get the index page of current result
	 *
	 * @return int
	 */
	function getIndexPage() {
		return $this->indexPage;
	}
	
	/**
	 * Set the index page for current result
	 *
	 * @param int $indexPage
	 */
	function setIndexPage($indexPage) {
		$this->indexPage = $indexPage;
	}
	
	/**
	 * Get the record number per page for current result
	 *
	 * @return int $recordPerPage
	 */
	function getRecordPerPage() {
		return $this->recordPerPage;
	}
	
	/**
	 * Set the record number per page for current result
	 *
	 * @param int $recordPerPage
	 */
	function setRecordPerPage($recordPerPage) {
		$this->recordPerPage = $recordPerPage;
	}
	
	/**
	 * Get the start index of the block records
	 *
	 * @return int
	 */
	function getStartRecordIndex() {
		if (empty ( $this->indexPage ) || $this->indexPage == 0) {
			return 0;
		}
		return ($this->indexPage - 1) * $this->recordPerPage;
	}
	
	/**
	 * Check if data is empty
	 *
	 * @return boolean
	 */
	function isEmptyRecord() {
		if (empty ( $this->recordSet ) || ! count ( $this->recordSet )) {
			return true;
		}
		return false;
	}
}
?>